package com.wh.minio.container;

import io.minio.MinioClient;
import io.minio.errors.MinioException;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;



public class FileUploader {



    public static void main(String[] args) throws NoSuchAlgorithmException, IOException, InvalidKeyException, XmlPullParserException {
        try {
            // Create a minioClient with the Minio Server name, Port, Access key and Secret key.
            MinioClient minioClient = new MinioClient("http://t.d.guijianyun.com:9008/", "EN1C0D65J0G2LDH70ADA", "QPHBlKqoWjBd8+k/aaxGh7SxB4qti8Qg0ULjH7AQ");

            // Check if the bucket already exists.
            boolean isExist = minioClient.bucketExists("asiatrip");
            if(isExist) {
                System.out.println("BucketDTO already exists.");
            } else {
                // Make a new bucket called asiatrip to hold a zip file of photos.
                minioClient.makeBucket("asiatrip");
            }



            // Upload the zip file to the bucket with putObject
            minioClient.putObject("asiatrip","13/13.png", "E:\\13\\13.png");



            System.out.println("/home/user/Photos/asiaphotos.zip is successfully uploaded as asiaphotos.zip to `asiatrip` bucket.");
        } catch(MinioException e) {
            System.out.println("Error occurred: " + e);
        }
    }

}
